//
//  AppDelegate.m
//  OCDemo
//
//  Created by 李含文 on 2021/4/22.
//

#import "AppDelegate.h"
#import "MyTabBarController.h"
#import "HWStability.h"
#import "HWRequestLogManage.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[HWStability shared] openProtection];
    [self createWindow];
    [self openRequestLogManage];
    return YES;
}

- (void)openRequestLogManage {
    HWRequestLogManage.shared.successBlock = ^BOOL(id  _Nonnull responseObject) { // responseObject类似AFN中请求成功返回的 响应体
        if (responseObject && [responseObject isKindOfClass:NSDictionary.class] && responseObject[@"code"]) { // 如果responseObject存在 并且responseObject[@"code"存在
            NSString *code = responseObject[@"code"];
            return code.integerValue == 200?YES:NO; // 如果code是200 说明服务器返回请求成功 反之
        }
        return YES;
    };
    [HWRequestLogManage shared].onlyURLs = @[@"baidu.com"]; // 只拦截域名包含 baidu.com 的请求
    [[HWRequestLogManage shared] openWithWindow:self.window]; //开启
}
- (void)createWindow {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = [[MyTabBarController alloc] init];
    [self.window makeKeyAndVisible];
    NSLog(@"%.2f", hw_statusBarHight);
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
    if ([url.absoluteString isEqualToString:@"MinisoEshopID"]) {
        NSLog(@"url->%@",url.absoluteString);
        
    }
    return YES;
}



@end

